//==============================================================================
//
// Title:       TrxAndFbSynthesizers.c
// Purpose:     A short description of the implementation.
//
// Created on:  2013-3-1 at 15:00:35 by Vinson.Zhang
// Copyright:   dafda. All Rights Reserved.
//
//==============================================================================

#include "RFBB.h"         
#include <utility.h>
#include <formatio.h>	  

//FMON_ACTION_SYNTHESIZER                              

_FRMON_TEST_STRUCT_CMD g_cFRMONNullingSynthCmd[7] = {{"FRMon,action,load,agent,MERAAccess,Vegas,_meraAccess","done"},
                                                        {"FRMon/Vegas/_meraAccess,action,init,MERAAccess,","done"},
                                                        {"FRMon/Vegas/_meraAccess,action,nullingSynthesizer,1","0x00"},
                                                        {"FRMon/Vegas/_meraAccess,action,nullingSynthesizer,2","0x00"},
                                                        {"FRMon/Vegas/_meraAccess,action,nullingSynthesizer,3","0x00"},
                                                        {"FRMon/Vegas/_meraAccess,action,nullingSynthesizer,4","0x00"},
														{"FRMon/Vegas/_meraAccess,action,terminate,MERAAccess","done"}};


_FRMON_TEST_STRUCT_CMD g_cFRMONTxFbLoopSynthCmd[7] = {{"FRMon,action,load,agent,MERAAccess,Vegas,_meraAccess","done"},
                                                        {"FRMon/Vegas/_meraAccess,action,init,MERAAccess,","done"},
                                                        {"FRMon/Vegas/_meraAccess,action,txSynthesizer,1","0x00"},
                                                        {"FRMon/Vegas/_meraAccess,action,txSynthesizer,2","0x00"},
                                                        {"FRMon/Vegas/_meraAccess,action,txSynthesizer,3","0x00"},
                                                        {"FRMon/Vegas/_meraAccess,action,txSynthesizer,4","0x00"},
														{"FRMon/Vegas/_meraAccess,action,terminate,MERAAccess","done"}};


_FRMON_TEST_STRUCT_CMD g_cFRMONRxAndLoopSynthCmd[7] = {{"FRMon,action,load,agent,MERAAccess,Vegas,_meraAccess","done"},
                                                        {"FRMon/Vegas/_meraAccess,action,init,MERAAccess,","done"},
                                                        {"FRMon/Vegas/_meraAccess,action,rxSynthesizer,1","0x00"},
                                                        {"FRMon/Vegas/_meraAccess,action,rxSynthesizer,2","0x00"},
                                                        {"FRMon/Vegas/_meraAccess,action,rxSynthesizer,3","0x00"},
                                                        {"FRMon/Vegas/_meraAccess,action,rxSynthesizer,4","0x00"},
														{"FRMon/Vegas/_meraAccess,action,terminate,MERAAccess","done"}};



_SHMON_TEST_LOOP_SYNTH_CMD g_szShmonTestLoopSynthCmd[2] ={
        {"rftestloop -c 1 1111 0 RX1 TX1 2000 1 10","Failure"},
        {"rftestloop -c 1 1111 0 RX1 TX1 1200 1 10","EGloReplyStatus_StatusOk"}};

_FRMON_TEST_STRUCT_CMD g_cFRMONTestLoopSynthCmd[4] = {{"FRMon,action,load,agent,MERAAccess,Vegas,_meraAccess","done"},
                                                        {"FRMon/Vegas/_meraAccess,action,init,MERAAccess,","done"},
                                                        {"FRMon/Vegas/_meraAccess,action,testLoopSynthesizer,","0x00"},
														{"FRMon/Vegas/_meraAccess,action,terminate,MERAAccess","done"}};

_SHMON_TEST_LOOP_SYNTH_CMD g_szShmonTestLoopSynthCmd_beforeFRMON[4] = {{"clockCleaner -set", "Number:"},
																	   {"1", "word"},
																	   {"0x00440A01", "0x00440A01"},
																	   {"\n", "done"}};


/**************************************************************************************************
  Function:        NullingSynthesizers
  Description:     This test is the tests the lock detect status of all synthesizers.
  Calls:           none
  Called By:       dll
  Table Accessed:  none
  Table Updated:   none
  Input:           none
  Output:          error code
  Return:          none
  Test Case ID:    FRHD_NullingSynthesizers
  Used Command:    g_cFRMONNullingSynthCmd
**************************************************************************************************/
void __decldllexp TX_TEST TxFbAndNullingSynthesizers(tTestData *testData, tTestError *testError)
{

    ErrMsg errMsg = {'\0'};
    ERRORINFO errorInfo;   
    ErrMsg szLogMsg;
    CAObjHandle hStepName = 0;
    char* pszStepName = NULL;
    char kszShmonAgent[BUFFER_SIZE_256] ={'\0'};   
    char szElementPath[BUFFER_SIZE_256] ={'\0'};
    double dTestNum = 0.0;
    int  error = 0;
    int  iPassFail = 0;
    int i = 0;
    int iPipeNum = 0;
    int iReturn = 0;
    long lSngthStatus = 0;
	int iArryNum = 0;
    //////////////////////////////////////////////////////////////////////////   
    // Resolve StepName 
    tsErrChk(TS_SeqContextGetProperty (testData->seqContextCVI, &errorInfo, 
                                       TS_SeqContextStep, CAVT_OBJHANDLE, 
                                       &hStepName));
    tsErrChk(TS_StepGetProperty (hStepName, &errorInfo, TS_StepName, CAVT_CSTRING, 
                                 &pszStepName));

    sprintf( szLogMsg, TEST_NAME_EVENT_FMTSTR, pszStepName );
    ErrChk( EELog_INEventLogLogEvent( g_hEventLog, NULL, szLogMsg ) );

    // Post message to GUI
    tsErrChk(TS_ThreadPostUIMessageEx (g_hThreadPostUIMessage, NULL,
                                       TS_UIMsg_ProgressText, 0.0,
                                       pszStepName, 0, VTRUE));

    //--------------------------------------------------------------------
    // Get Test Parameters from Sequence FileGlobals    
    sprintf(szElementPath, "%s.%s.PARAMETERS.TestNum", TESTPLAN_BASE_PATH, pszStepName );   
    tsErrChk(TS_PropertyGetValNumber(testData->seqContextCVI, &errorInfo, szElementPath, 0, &dTestNum));

    if((dTestNum >= 1) && (dTestNum <= 4))
    	{
        i = dTestNum;
    	}
    else
		{
		goto Error;
		}
	
    //If it's pipel1, do Load and Initial 
	if(dTestNum == 1)
    	{
			//InetTelnetOpen(FRCommand)   
			g_hFrmonAgent = RfbbInetTelnetOpen (g_szDUTIP, g_iPort, 0);          

    	for(iArryNum = 0;iArryNum < 2;iArryNum++)
    		{
        	sprintf(kszShmonAgent,g_cFRMONNullingSynthCmd[iArryNum].cWriteFrmonCmd);    
      		FRmonAgent_String(kszShmonAgent, -1,g_cFRMONNullingSynthCmd[iArryNum].cReturnValue, &iPassFail);
	
        	if (iPassFail!=1) 
        		{
				 //action terminate
    			sprintf(kszShmonAgent,g_cFRMONNullingSynthCmd[6].cWriteFrmonCmd);
    			Frmon_RunCmdNoAck(kszShmonAgent, 1); 
    		
				//InetTelnetClose(FRCommand)  
				InetTelnetClose(g_hFrmonAgent);
            	goto Error;
        		}
			
			}
		}
	
		//Normal Actiong of test
		sprintf(kszShmonAgent,g_cFRMONNullingSynthCmd[i + 1].cWriteFrmonCmd);    
      	FRmonAgent_String(kszShmonAgent, -1,g_cFRMONNullingSynthCmd[i + 1].cReturnValue, &iPassFail);
		Delay(1);
		
	//If pipel4 was done, terminate	
    if(dTestNum == 4) 
		{
			 //action terminate
    		sprintf(kszShmonAgent,g_cFRMONNullingSynthCmd[6].cWriteFrmonCmd);
    		Frmon_RunCmdNoAck(kszShmonAgent, 1); 
    		
			//InetTelnetClose(FRCommand) 
			InetTelnetClose(g_hFrmonAgent);
            	goto Error;
		}
       
Error:
        
#if(ON_OFF != SIMU_VERS) 
		
    
    if(iPassFail == 1)
    	{
        testData->result = PASS;
    	}
    else 
    	{
        testData->result = FAIL;
    	}

    // FREE RESOURCES 
    CA_DISCARD_OBJ( hStepName );
    CA_FREE( pszStepName );

    // If an error occurred, set the error flag to cause a run-time error in TestStand.
    if(error < 0)
    	{
        testError->errorFlag = TRUE;
        testError->errorCode = error;
        testData->replaceStringFuncPtr(&testError->errorMessage, errMsg);
    	}
#else
    testData->result = PASS;
#endif

   // Clear message from GUI
   TS_ThreadPostUIMessageEx (g_hThreadPostUIMessage, NULL,
                                 TS_UIMsg_ProgressText, 0.0, " ", 0, VTRUE);

   return;    
}

/**************************************************************************************************
  Function:        RxSynthesizers
  Description:     This test is the tests the lock detect status of RXsynthesizers.
  Calls:           none
  Called By:       dll
  Table Accessed:  none
  Table Updated:   none
  Input:           none
  Output:          error code
  Return:          none
  Test Case ID:    FRHD_RxSynthesizers
  Used Command:    g_cFRMONRxAndLoopSynthCmd
**************************************************************************************************/
void __decldllexp TX_TEST RxSynthesizers(tTestData *testData, tTestError *testError)
{
       ErrMsg errMsg = {'\0'};
        ERRORINFO errorInfo;   
        ErrMsg szLogMsg;
        CAObjHandle hStepName = 0;
        char* pszStepName = NULL;
        char kszShmonAgent[BUFFER_SIZE_256] ={'\0'};   
        char szElementPath[BUFFER_SIZE_256] ={'\0'};
        double dTestNum = 0.0;
        int  error = 0;
        int  iPassFail = 0;
        int i = 0;
        int iPipeNum = 0;
        int iReturn = 0;
        long int lSngthStatus = 0;
		int iArryNum = 0;
        //////////////////////////////////////////////////////////////////////////   
        // Resolve StepName 
        tsErrChk(TS_SeqContextGetProperty (testData->seqContextCVI, &errorInfo, 
                                           TS_SeqContextStep, CAVT_OBJHANDLE, 
                                           &hStepName));
        tsErrChk(TS_StepGetProperty (hStepName, &errorInfo, TS_StepName, CAVT_CSTRING, 
                                     &pszStepName));
    
        sprintf( szLogMsg, TEST_NAME_EVENT_FMTSTR, pszStepName );
        ErrChk( EELog_INEventLogLogEvent( g_hEventLog, NULL, szLogMsg ) );
    
        // Post message to GUI
        tsErrChk(TS_ThreadPostUIMessageEx (g_hThreadPostUIMessage, NULL,
                                           TS_UIMsg_ProgressText, 0.0,
                                           pszStepName, 0, VTRUE));
    
        //--------------------------------------------------------------------
        // Get Test Parameters from Sequence FileGlobals    
        sprintf(szElementPath, "%s.%s.PARAMETERS.TestNum", TESTPLAN_BASE_PATH, pszStepName );   
        tsErrChk(TS_PropertyGetValNumber(testData->seqContextCVI, &errorInfo, szElementPath, 0, &dTestNum));
    
        if((dTestNum >= 1) && (dTestNum <= 4))
    		{
        	i = dTestNum;
    		}
    	else
			{
			goto Error;
			}	
        
        //If it's pipel1, do Load and Initial
		if(dTestNum == 1)
    		{
			//InetTelnetOpen(FRCommand) 	
    		g_hFrmonAgent = RfbbInetTelnetOpen (g_szDUTIP, g_iPort, 0);          

    		for(iArryNum = 0;iArryNum < 2;iArryNum++)
    			{
        		sprintf(kszShmonAgent,g_cFRMONRxAndLoopSynthCmd[iArryNum].cWriteFrmonCmd);    
      			FRmonAgent_String(kszShmonAgent, -1,g_cFRMONRxAndLoopSynthCmd[iArryNum].cReturnValue, &iPassFail);
	
        		if (iPassFail!=1) 
        			{
					//action terminate
    				sprintf(kszShmonAgent,g_cFRMONRxAndLoopSynthCmd[6].cWriteFrmonCmd);
    				Frmon_RunCmdNoAck(kszShmonAgent, 1); 
    		
					//InetTelnetClose(FRCommand)
					InetTelnetClose(g_hFrmonAgent);
            		goto Error;
        			}
				}
			}
		
		//Normal Actiong of test 
		sprintf(kszShmonAgent,g_cFRMONRxAndLoopSynthCmd[i + 1].cWriteFrmonCmd);    
      	FRmonAgent_String(kszShmonAgent, -1,g_cFRMONRxAndLoopSynthCmd[i + 1].cReturnValue, &iPassFail);
		Delay(1);
		
		//If pipel4 was done, terminate	 
		if(dTestNum == 4) 
			{
				//action terminate
    			sprintf(kszShmonAgent,g_cFRMONRxAndLoopSynthCmd[6].cWriteFrmonCmd); 
    			Frmon_RunCmdNoAck(kszShmonAgent, 1); 
    			
				//InetTelnetClose(FRCommand) 
				InetTelnetClose(g_hFrmonAgent);
            	goto Error;
			}
       
    Error:
        
#if(ON_OFF != SIMU_VERS)
		
        
        if(iPassFail == 1)
        	{
            testData->result = PASS;
        	}
        else 
        	{
            testData->result = FAIL;
        	}

        // FREE RESOURCES
        CA_DISCARD_OBJ( hStepName );
        CA_FREE( pszStepName );
    
        // If an error occurred, set the error flag to cause a run-time error in TestStand.
        if(error < 0)
        	{
            testError->errorFlag = TRUE;
            testError->errorCode = error;
            testData->replaceStringFuncPtr(&testError->errorMessage, errMsg);
        	}
#else
        testData->result = PASS;
#endif
    
       // Clear message from GUI
       TS_ThreadPostUIMessageEx (g_hThreadPostUIMessage, NULL,
                                     TS_UIMsg_ProgressText, 0.0, " ", 0, VTRUE);
    
       return;    

}
/**************************************************************************************************
  Function:        TXFBSynthesizers
  Description:     This test is the tests the lock detect status of all synthesizers.
  Calls:           none
  Called By:       dll
  Table Accessed:  none
  Table Updated:   none
  Input:           none
  Output:          error code
  Return:          none
  Test Case ID:    FRHD_TXFBSynthesizers
  Used Command:    g_cFRMONTxFbLoopSynthCmd
**************************************************************************************************/
void __decldllexp TX_TEST TXFBSynthesizers(tTestData *testData, tTestError *testError)
{
       ErrMsg errMsg = {'\0'};
        ERRORINFO errorInfo;   
        ErrMsg szLogMsg;
        CAObjHandle hStepName = 0;
        char* pszStepName = NULL;
        char kszShmonAgent[BUFFER_SIZE_256] ={'\0'};   
        char szElementPath[BUFFER_SIZE_256] ={'\0'};
        double dTestNum = 0.0;
        int  error = 0;
        int  iPassFail = 0;
        int i = 0;
        int iPipeNum = 0;
        int iReturn = 0;
        long int lSngthStatus = 0;
		int iArryNum = 0; 
        //////////////////////////////////////////////////////////////////////////   
        // Resolve StepName 
        tsErrChk(TS_SeqContextGetProperty (testData->seqContextCVI, &errorInfo, 
                                           TS_SeqContextStep, CAVT_OBJHANDLE, 
                                           &hStepName));
        tsErrChk(TS_StepGetProperty (hStepName, &errorInfo, TS_StepName, CAVT_CSTRING, 
                                     &pszStepName));
    
        sprintf( szLogMsg, TEST_NAME_EVENT_FMTSTR, pszStepName );
        ErrChk( EELog_INEventLogLogEvent( g_hEventLog, NULL, szLogMsg ) );
    
        // Post message to GUI
        tsErrChk(TS_ThreadPostUIMessageEx (g_hThreadPostUIMessage, NULL,
                                           TS_UIMsg_ProgressText, 0.0,
                                           pszStepName, 0, VTRUE));
    
        //--------------------------------------------------------------------
        // Get Test Parameters from Sequence FileGlobals    
        sprintf(szElementPath, "%s.%s.PARAMETERS.TestNum", TESTPLAN_BASE_PATH, pszStepName );   
        tsErrChk(TS_PropertyGetValNumber(testData->seqContextCVI, &errorInfo, szElementPath, 0, &dTestNum));
    
        if((dTestNum >= 1) && (dTestNum <= 4))
    		{
        	i = dTestNum;
    		}
    	else
			{
			goto Error;
			}	
        
        //If it's pipel1, do Load and Initial 
		if(dTestNum == 1)
    		{
			//InetTelnetOpen(FRCommand) 
        	g_hFrmonAgent = RfbbInetTelnetOpen (g_szDUTIP, g_iPort, 0);          
			
    		for(iArryNum = 0;iArryNum < 2;iArryNum++)
    			{
        		sprintf(kszShmonAgent,g_cFRMONTxFbLoopSynthCmd[iArryNum].cWriteFrmonCmd);    
      			FRmonAgent_String(kszShmonAgent, -1,g_cFRMONTxFbLoopSynthCmd[iArryNum].cReturnValue, &iPassFail);
	
        		if (iPassFail!=1) 
        			{
            		 //action terminate
    				sprintf(kszShmonAgent,g_cFRMONTxFbLoopSynthCmd[6].cWriteFrmonCmd);
    				Frmon_RunCmdNoAck(kszShmonAgent, 1); 
    		
					//InetTelnetClose(FRCommand) 
					InetTelnetClose(g_hFrmonAgent);
					goto Error;
        			}
				}
			}
		//Normal Actiong of test
		sprintf(kszShmonAgent,g_cFRMONTxFbLoopSynthCmd[i + 1].cWriteFrmonCmd);    
      	FRmonAgent_String(kszShmonAgent, -1,g_cFRMONTxFbLoopSynthCmd[i + 1].cReturnValue, &iPassFail);
		Delay(1);
		
		//If pipel4 was done, terminate	
		if(dTestNum == 4) 
			{
			//action terminate
    		sprintf(kszShmonAgent,g_cFRMONTxFbLoopSynthCmd[6].cWriteFrmonCmd); 
    		Frmon_RunCmdNoAck(kszShmonAgent, 1); 
    		
			//InetTelnetClose(FRCommand) 
			InetTelnetClose(g_hFrmonAgent);
            goto Error;
			}
			
    Error:
        
#if(ON_OFF != SIMU_VERS)
			
        
        if(iPassFail == 1)
        	{
            testData->result = PASS;
        	}
        else 
        	{
            testData->result = FAIL;
       		}	
    
        
        // FREE RESOURCES
        CA_DISCARD_OBJ( hStepName );
        CA_FREE( pszStepName );
    
        // If an error occurred, set the error flag to cause a run-time error in TestStand.
        if(error < 0)
        	{
            testError->errorFlag = TRUE;
            testError->errorCode = error;
            testData->replaceStringFuncPtr(&testError->errorMessage, errMsg);
        	}
#else
        testData->result = PASS;
#endif
    
       // Clear message from GUI
       TS_ThreadPostUIMessageEx (g_hThreadPostUIMessage, NULL,
                                     TS_UIMsg_ProgressText, 0.0, " ", 0, VTRUE);
    
       return;    

}

/**************************************************************************************************
  Function:        TestLoopSynthesizer
  Description:     This test is the tests the lock detect status of TestLoopSynthesizer.
  Calls:           none
  Called By:       dll
  Table Accessed:  none
  Table Updated:   none
  Input:           none
  Output:          error code
  Return:          none
  Test Case ID:    FRHD_TestLoopSynthesizer
  Used Command:    g_cFRMONTestLoopSynthCmd
**************************************************************************************************/
void __decldllexp TX_TEST TestLoopSynthesizer(tTestData *testData, tTestError *testError)
{
       ErrMsg errMsg = {'\0'};
        ERRORINFO errorInfo;   
        ErrMsg szLogMsg;
        CAObjHandle hStepName = 0;
        char* pszStepName = NULL;
        char kszShmonAgent[BUFFER_SIZE_256] ={'\0'};   
        char szElementPath[BUFFER_SIZE_256] ={'\0'};
        char szReturnString[BUF_SIZE_32K + 1] = {'\0'};
        double dTestNum = 0.0;
        int  error = 0;
        int  iPassFail = 0;
        int i = 0;
        int iPipeNum = 0;
        int iReturn = 0;
        long lSngthStatus = 0;
		int iArryNum = 0;
        //////////////////////////////////////////////////////////////////////////   
        // Resolve StepName 
        tsErrChk(TS_SeqContextGetProperty (testData->seqContextCVI, &errorInfo, 
                                           TS_SeqContextStep, CAVT_OBJHANDLE, 
                                           &hStepName));
        tsErrChk(TS_StepGetProperty (hStepName, &errorInfo, TS_StepName, CAVT_CSTRING, 
                                     &pszStepName));
    
        sprintf( szLogMsg, TEST_NAME_EVENT_FMTSTR, pszStepName );
        ErrChk( EELog_INEventLogLogEvent( g_hEventLog, NULL, szLogMsg ) );
    
        // Post message to GUI
        tsErrChk(TS_ThreadPostUIMessageEx (g_hThreadPostUIMessage, NULL,
                                           TS_UIMsg_ProgressText, 0.0,
                                           pszStepName, 0, VTRUE));
    
        //--------------------------------------------------------------------
        // Get Test Parameters from Sequence FileGlobals    
        sprintf(szElementPath, "%s.%s.PARAMETERS.TestNum", TESTPLAN_BASE_PATH, pszStepName );   
        tsErrChk(TS_PropertyGetValNumber(testData->seqContextCVI, &errorInfo, szElementPath, 0, &dTestNum));
		

/*		For 23.04.R07
		//Shell Command------------------------------------------------------------
    
        g_hShellCommand = RfbbInetTelnetOpen (g_szDUTIP, g_iShellCommandPort, 0); 
    
        //run Shellcommands    
        
		for(i = 0;i < 2;i++)
		{
			sprintf(kszShmonAgent,g_szShmonTestLoopSynthCmd[i].cSetTestSynthCmd);
        	if(ShellCommandWriteReadUntil(kszShmonAgent,g_szShmonTestLoopSynthCmd[i].cReadSynthStat, szReturnString,5000,1) != 0) 
        		{
            	sprintf(errMsg, "OseWriteReadUntil() - failed");
				ErrChk( EELog_INEventLogLogEvent( g_hEventLog, NULL, errMsg ) );  
            	iPassFail = 0;
            	error = -1;
            	goto Error;
        		}
			 iPassFail = 1; 
		}	
    
Error:
        
#if(ON_OFF != SIMU_VERS) 
        
        if(iPassFail == 1)
        {
            testData->result = PASS;
        }
        else 
        {
            testData->result = FAIL;
        }
		//InetTelnetClose(g_hShellCommand);
        InetTelnetClose(g_hShellCommand);
         
        // FREE RESOURCES
        CA_DISCARD_OBJ( hStepName );
        CA_FREE( pszStepName );
        
        // If an error occurred, set the error flag to cause a run-time error in TestStand.
        if(error < 0)
        {
            testError->errorFlag = TRUE;
            testError->errorCode = error;
            testData->replaceStringFuncPtr(&testError->errorMessage, errMsg);
        }
#else
        testData->result = PASS;
#endif
    
       // Clear message from GUI
       TS_ThreadPostUIMessageEx (g_hThreadPostUIMessage, NULL,
                                     TS_UIMsg_ProgressText, 0.0, " ", 0, VTRUE);
    
       return;
} end 23.04.R07*/
//  FRMon need modify VEG23.04.R07________________________________________________________________________

		//InetTelnetOpen(FRCommand)
  		g_hFrmonAgent = RfbbInetTelnetOpen (g_szDUTIP, g_iPort, 0);    
		Delay(0.5);
		
		/* BeforeFRMON
		g_hShellCommand = RfbbInetTelnetOpen (g_szDUTIP, g_iShellCommandPort, 0); 
		for(iArryNum = 0;iArryNum < 4;iArryNum++)
		{
			
			sprintf(kszShmonAgent,g_szShmonTestLoopSynthCmd_beforeFRMON[iArryNum].cSetTestSynthCmd); 
        	if(ShellCommandWriteReadUntil(kszShmonAgent,g_szShmonTestLoopSynthCmd_beforeFRMON[iArryNum].cReadSynthStat, szReturnString,5000,1) != 0) 
        	{
            	sprintf(errMsg, "OseWriteReadUntil() - failed");
				ErrChk( EELog_INEventLogLogEvent( g_hEventLog, NULL, errMsg ) );  
            	iPassFail = 0;
            	error = -1;
            	goto Error;
        	}			
		}
		*/

    	for(iArryNum = 0;iArryNum < 3;iArryNum++)
    	{
        	sprintf(kszShmonAgent,g_cFRMONTestLoopSynthCmd[iArryNum].cWriteFrmonCmd);    
      		FRmonAgent_String(kszShmonAgent, -1,g_cFRMONTestLoopSynthCmd[iArryNum].cReturnValue, &iPassFail);
			//Some delay 
			Delay(1);
	
        	if (iPassFail!=1) 
        		{
            goto Error;
        		}
    	}
	
		
       
Error:
        
#if(ON_OFF != SIMU_VERS) 
		 //action terminate
    sprintf(kszShmonAgent,g_cFRMONTestLoopSynthCmd[3].cWriteFrmonCmd);
    Frmon_RunCmdNoAck(kszShmonAgent, 1); 
        
        if(iPassFail == 1)
        	{
            testData->result = PASS;
        	}
        else 
        	{
            testData->result = FAIL;
        	}
    
        //InetTelnetClose(FRCommand)
		InetTelnetClose(g_hFrmonAgent);
		//InetTelnetClose(g_hShellCommand);  
        
		// FREE RESOURCES
		CA_DISCARD_OBJ( hStepName );
        CA_FREE( pszStepName );
    
        // If an error occurred, set the error flag to cause a run-time error in TestStand.
        if(error < 0)
        	{
            testError->errorFlag = TRUE;
            testError->errorCode = error;
            testData->replaceStringFuncPtr(&testError->errorMessage, errMsg);
        	}
#else
        testData->result = PASS;
#endif
    
       // Clear message from GUI
       TS_ThreadPostUIMessageEx (g_hThreadPostUIMessage, NULL,
                                     TS_UIMsg_ProgressText, 0.0, " ", 0, VTRUE);
    
       return;    

}


// ************************* 78 character ruler *****************************
//                           End of source file
// **************************************************************************
